import { serviceCreate } from '../utils/request'
import { merge } from 'axios/lib/utils'
const http = serviceCreate({
  // baseURL: '/dv',
  // 表单提交
  emulateJSON: true
})
// @config {headers, emulateJSON, loading, msg, errMsg, disableInterceptor}
const methods = {
    // 获取视频详细数据
    getVideo (params, config) {
        params = merge({
            bvid: ''
        }, params || {})
        return http.get('/video/getDetail', merge(config, { params }))
    },
    // 获取视频播放地址
    getPlayUrl (params, config) {
        params = merge({
            // 视频相关id
            cid: '',
            // 参数值是详细数据里面的aid
            avid: '',
            bvid: '',
            // 播放平台
            platform: 'h5',
            // 返回数据格式
            otype: 'json',
            // 视频质量
            qn: 16,
            type: 'mp4',
            html5: 1
        }, params || {})
        return http.get('/video/getPlayUrl', merge(config, { params }))
    },
    // 获取视频相关标签
    getVideoTags (params, config) {
        params = merge({
            aid: '',
            bvid: ''
        }, params || {})
        return http.get('/video/getTag', merge(config, { params }))
    },
    // 获取相同类型的视频
    getVideoRelated (params, config) {
        params = merge({
            aid: '',
            bvid: '',
            context: ''
        }, params || {})
        return http.get('/video/getRelated', merge(config, { params }))
    },
    // 获取视频评论
    getVideoComments (params, config) {
        params = merge({
            // 参数值是详细数据里面的aid
            oid: '',
            bvid: '',
            type: 1
        }, params || {})
        return http.get('/video/getComment', merge(config, { params }))
    }
}

export default methods
